
ENT.Spawnable			= false
ENT.AdminSpawnable		= false

include('shared.lua')

local matBall = Material( "sprites/sent_ball" )

language.Add( "malawar_xcannonround", "xcannon Round" )

function ENT:Draw()
	local pos = self.Entity:GetPos()
	local vel = self.Entity:GetVelocity()
	local radius = self.Entity:GetNetworkedInt('ShellRadius')
	local maxTrail = self.Entity:GetNetworkedInt('TrailLength')
	render.SetMaterial( matBall )


	if self.history == nil then	self.history = {} end
	if self.framecount == nil then self.framecount = 0 end

	for k, oldpos in pairs(self.history) do
		local mix = 1 - k/maxTrail
		local col = Color(0, 0, 0, 150 * mix)
		
		render.DrawSprite( oldpos, radius * 2, radius * 2, col)
	end
			
	render.DrawSprite( pos, radius*2, radius*2, Color(0,0,0) )
end

function ENT:Think() -- store history even if we're not looking at our balls.
	if self.history == nil then	self.history = {} end
	if self.framecount == nil then self.framecount = 0 end
	local maxTrail = self.Entity:GetNetworkedInt('TrailLength')
	
		table.insert(self.history,1,self.Entity:GetPos())
		if table.getn(self.history) > maxTrail then
			table.remove(self.history)
		end
end 